package jim.coly.jetty9;

import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
import org.eclipse.jetty.server.handler.ResourceHandler;

public class JettyStarter {

	public static void main(String[] args) throws Exception {

		Server server = new Server();
		ServerConnector connector = new ServerConnector(server);
		connector.setPort(8090);
		// connector.setIdleTimeout(30000);
		server.setConnectors(new Connector[] { connector });

		ContextHandler context0 = new ContextHandler();
		context0.setContextPath("/web");
		ResourceHandler rh0 = new ResourceHandler();
		rh0.setResourceBase("./src/main/webapp");
		context0.setHandler(rh0);

		ContextHandlerCollection contexts = new ContextHandlerCollection();
		contexts.setHandlers(new Handler[] { context0 });

		server.setHandler(contexts);

		server.start();
		server.join();
	}
}